# s = "egg"
# t = "add"

# s = "foo"
# t = "bar"
s = "paper"
t = "title"
def isIsomorphic(s: str, t: str) -> bool:
    #做一个字典
    s_dictionary=dict()
    t_dictionary=dict()
    s_pointer,t_pointer=0,0
    strLen=len(s)
    while s_pointer<strLen and t_pointer<strLen:
        if s[s_pointer] not in set(s_dictionary.keys()) and t[t_pointer] not in set(t_dictionary.keys()):
            #当前的映射关系是合理的，并且没有存入到字典中
            s_dictionary[s[s_pointer]]=t[t_pointer]
            t_dictionary[t[t_pointer]]=s[s_pointer]
            s_pointer+=1
            t_pointer+=1
        elif s[s_pointer] in set(s_dictionary.keys()) and s_dictionary[s[s_pointer]]==t[t_pointer]:
            #映射关系匹配成功
            s_pointer+=1
            t_pointer+=1
        else:
            return False

    return True

print(isIsomorphic(s,t))

